package com.deep.deepenterpise.model.vo;

import lombok.Data;

import java.util.Collections;
import java.util.List;

/**
 * @author xyz
 * @version 1.0
 * @title DrBasePageVo
 * @description
 * @create 2024/4/17 09:17
 */
@Data
public class DrPageBaseVo {
    private List<?> drData;
    private Integer drPage;
    private Long drCount;

    public DrPageBaseVo(Integer drPage, Integer drSize, Long drCount) {
        this.drPage = drPage;
        this.drCount = drCount == null ? 0 : calculateTotalPages(drCount.intValue(), drSize);
        this.drData = Collections.emptyList();
    }

    public DrPageBaseVo() {
    }

    public static long calculateTotalPages(long totalCount, int pageSize) {
        // 使用 Math.ceil() 方法向上取整
        return (int) Math.ceil((double) totalCount / pageSize);
    }
}
